package com.electromagnetic.industry.software.manage.controller;

import com.electromagnetic.industry.software.common.annotations.UserOperation;
import com.electromagnetic.industry.software.common.enums.UserOperationModuleEnum;
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
import com.electromagnetic.industry.software.manage.service.PermissionService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/data/ed/permission")
public class PermissionController {

    @Resource
    private PermissionService permissionService;

    @GetMapping(value = "/{id}")
    @UserOperation(value = "查询了在当前目录的功能权限", modelName = UserOperationModuleEnum.PERMISSION)
    public ElectromagneticResult<?> getUserPermission(@PathVariable("id") String id) {
        String userId = UserThreadLocal.getUserId();
        return ElectromagneticResultUtil.success(permissionService.getUserPermission(userId, id, false));
    }

}
